"""面向对象编程示例：宠物商店管理系统"""

class Animal:
    def __init__(self, name, age, species):
        """构造器"""
        self.__name = name    # 私有属性
        self.__age = age      # 私有属性
        self.species = species

    @property    # 属性装饰器
    def name(self):
        return self.__name
                                                                    
    @property
    def age(self):
        return self.__age

    def make_sound(self):
        pass    # 抽象方法，由子类实现

    def get_info(self):
        return f"这是一只{self.species}，名字叫{self.__name}，年龄{self.__age}岁"

# 继承
class Dog(Animal):
    def __init__(self, name, age, breed):
        super().__init__(name, age, "狗")
        self.breed = breed    # 品种

    def make_sound(self):
        return "汪汪汪！"

    def special_skill(self):
        return "我会看家护院！"


class Cat(Animal):
    def __init__(self, name, age, color):
        super().__init__(name, age, "猫")
        self.color = color    # 毛色

    def make_sound(self):
        return "喵喵喵～"

    def special_skill(self):
        return "我会抓老鼠！"


class PetShop:
    def __init__(self):
        self.pets = []

    def add_pet(self, pet):
        self.pets.append(pet)

    def list_pets(self):
        for pet in self.pets:
            print(pet.get_info())
            print(f"叫声：{pet.make_sound()}")
            if isinstance(pet, (Dog, Cat)):
                print(f"特殊技能：{pet.special_skill()}")
            print("-" * 30)


# 测试代码
if __name__ == "__main__":
    # 创建宠物商店
    shop = PetShop()

    # 添加宠物
    dog1 = Dog("旺财", 2, "金毛")
    cat1 = Cat("咪咪", 1, "橘色")
    
    shop.add_pet(dog1)
    shop.add_pet(cat1)

    # 展示所有宠物信息
    print("欢迎来到宠物商店！以下是我们的宠物：")
    shop.list_pets()
